// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require(CONFIG.BasePath + "js/enterprise/base");
	var router = require("../hash/pageRouter");
	var footer = require("../footer/footer_gray");
	var top = require("../top/top_main");
	var constant = require("constant");
	var databind = require("databind");
	var dialog = require("dialog");
	var css_enterpriseDetail = require("./myLines.css");
	var tools = require("tools");
	var init = function() {
		inquireEnterpriseFinanceSummaryPageList();
		router.init();
		initEvent();
	};

	var initEvent = function() {
		if (base.getData("sid") == null) {
			location.href = "../login/login.html";
		}
		
	};
	
	//查询企业融资汇总信息
	var inquireEnterpriseFinanceSummaryPageList = function() {
		base.fnAjax({
			action: "inquireEnterpriseFinanceSummaryPageList.json",
			async: false,
			oData: {
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					if (data.datas.length != 0) {
						data.datas[0].shouldReturn = data.datas[0].totalLoanAmount - data.datas[0].totalRepayAmount;
						data.datas[0].creditRemaining = data.datas[0].creditLine - data.datas[0].creditLineAlready;
						databind.fillForm($("#myLines"), data.datas[0]);
						if ($("#myLines input[name=shouldReturn]").val()*1 < 0) {
							$("#myLines input[name=shouldReturn]").val("0");
						}
						if ($("#myLines .data[name=creditRemaining]").html()*1 < 0) {
							$("#myLines .data[name=creditRemaining]").html("0");
						}
					}
				} else {}
			}
		});
	};
	
	return {
		init: init
	};
});